package com.chance.cc.crawler.development.command.schedule.ifeng;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.development.command.job.domain.ifeng.health.realtime.IFengHealthRealtimeCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.job.domain.ifeng.health.trace.IFengHealthTraceCrawlerSchedulerJob;
import com.chance.cc.crawler.development.command.schedule.CrawlerJobScheduleCommand;
import org.junit.Test;

/**
 * @author lt
 * @version 1.0
 * @date 2021-02-09 23:32:43
 * @email okprog@sina.com
 */
public class IFengCrawlerJobScheduler {
    private static String domain = "ifeng";
    private static CrawlerJobScheduleCommand crawlerJobScheduleCommand =
            new CrawlerJobScheduleCommand("192.168.1.215",9589);
    private static String device_name = "crawler_dev_host";

    /**
     * 删除调度
     */
    @Test
    public void delSchedulerJob(){
        CrawlerJob crawlerJob = IFengHealthTraceCrawlerSchedulerJob.crawlerScheduler();
        String triggerKey = crawlerJob.generateCrawlerTriggerKey();
        HttpPage httpPage = crawlerJobScheduleCommand.deleteCrawlerJob(triggerKey, device_name);
        System.out.println("delete crawler job : " + httpPage.getRawText());
    }

    @Test
    public void WYHealthRealtimeJobScheduler(){
        CrawlerJob crawlerJob = IFengHealthRealtimeCrawlerSchedulerJob.crawlerScheduler();
        String triggerKey = crawlerJob.generateCrawlerTriggerKey();
//        crawlerJobScheduleCommand.publishCrawlerJob(triggerKey,device_name);
        crawlerJobScheduleCommand.republishCrawlerJob(triggerKey,device_name);
    }

    @Test
    public void WYHealthTraceJobScheduler(){
        CrawlerJob crawlerJob = IFengHealthTraceCrawlerSchedulerJob.crawlerScheduler();
        String triggerKey = crawlerJob.generateCrawlerTriggerKey();
//        crawlerJobScheduleCommand.publishCrawlerJob(triggerKey,device_name);
        crawlerJobScheduleCommand.republishCrawlerJob(triggerKey,device_name);
    }
}
